package jp.sourceforge.akjrcp.util;

import org.eclipse.swt.dnd.DND;
import org.eclipse.swt.dnd.DropTarget;
import org.eclipse.swt.dnd.DropTargetAdapter;
import org.eclipse.swt.dnd.DropTargetEvent;
import org.eclipse.swt.dnd.FileTransfer;
import org.eclipse.swt.dnd.Transfer;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;

public class DropFileMonitor extends DropTargetAdapter {
	private DropFileListener listener;
	public DropFileMonitor(Control controler,DropFileListener listener){
		Transfer[] types = new Transfer[] { FileTransfer.getInstance() };

		int operations = DND.DROP_MOVE | DND.DROP_COPY;

		DropTarget target2 = new DropTarget(controler, operations);
		target2.setTransfer(types);

		target2.addDropListener(this);
		this.listener=listener;
	}
	public void dragEnter(DropTargetEvent event) {
		// log.infodrag enter:"+event.data);
	}

	public void dragOver(DropTargetEvent event) {
		// log.infodrag over:"+event.data);
	}

	public void drop(DropTargetEvent event) {
		
		

		// log.info(event.data.getClass().getName());
		String files[] = (String[]) event.data;

		
			listener.dropFile(files);
			
			
		

		
	}
}